package com.dy.design_pattern_study.observer_mode.dome2_decoupling;

import com.dy.design_pattern_study.observer_mode.dome2_decoupling.notifier_code.impl.Boss;
import com.dy.design_pattern_study.observer_mode.dome2_decoupling.observer_code.impl.NBAObServer;
import com.dy.design_pattern_study.observer_mode.dome2_decoupling.observer_code.impl.StockObServer;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-04
 * @Content
 */
public class Client {
    public static void main(String[] args) {

        //什么是观察者模式？

        //这个是通知类
        Boss boss = new Boss();

        //这两个类是观察者类
        StockObServer obServer = new StockObServer("A1", boss);
        NBAObServer nbaObServer = new NBAObServer("A2", boss);

        //通知类，可以选择通知不同观察者类
        boss.Attach(obServer);
        boss.Attach(nbaObServer);

        boss.Detach(obServer);

        boss.setAction("I come");

        //通知完毕后，观察者会做相应的动作
        boss.Notify();
    }
}
